import {defineConfig, loadEnv} from 'vite'
import vue from '@vitejs/plugin-vue'
import legacy from '@vitejs/plugin-legacy'
import pkg from './package.json'
import {resolve} from "path"

// import styleImport from 'vite-plugin-style-import'
const mode = 'development'
const env = loadEnv(mode, './')

// https://vitejs.dev/config/
export default defineConfig({
    mode: mode,
    build: {
        target: 'es2015',
        staticInlineLimit: 1024,
        assetsDir: 'static', // 修改 assets 目录名为 static
    },
    // server: {
    //     port: 9596,
    //     proxy: {
    //         '/api': {
    //             target: env.VITE_PROXY_URL || '',
    //             changeOrigin: true,
    //         }
    //     },
    //     cors: true
    // },
    server:{
       host:'0.0.0.0'
    },
    resolve: {
        alias: {
            "@": resolve(__dirname, "src"),
        }
    },
    define: {
        __APP_VERSION__: JSON.stringify(pkg.version),
    },
    plugins: [
        vue(),
        legacy({
            targets: ['defaults', 'not IE 11']
        }),
        /* styleImport({
          libs: [{
            libraryName: 'element-plus',
            esModule: true,
            ensureStyleFile: true,
            resolveStyle: (name) => {
              name = name.slice(3)
              return `element-plus/packages/theme-chalk/src/${name}.scss`;
            },
            resolveComponent: (name) => {
              return `element-plus/lib/${name}`;
            },
          }]
        }) */
    ]
})
